﻿using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace Koala.Pro.Core.Models;

[SugarTable("T_ACL_OU")]
public class OuInfo : Entity<int>
{
    [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
    public override int Id { get; set; }

    public virtual int? PID { get; set; }

    public virtual string HandNo { get; set; }

    [Required]
    public virtual string Name { get; set; }

    public virtual string SortCode { get; set; }

    public virtual string Category { get; set; }

    public virtual string Address { get; set; }

    public virtual string OuterPhone { get; set; }

    public virtual string InnerPhone { get; set; }

    public virtual string Note { get; set; }

    public virtual string Creator { get; set; }

    public virtual string Creator_ID { get; set; }

    public virtual DateTime? CreateTime { get; set; }

    public virtual string Editor { get; set; }

    public virtual string Editor_ID { get; set; }

    public virtual DateTime? EditTime { get; set; }

    public virtual int? Deleted { get; set; } = 0;

    public virtual int? Enabled { get; set; } = 1;

    public virtual string Company_ID { get; set; }

    public virtual string CompanyName { get; set; }

    [SugarColumn(IsIgnore = true)]
    public virtual bool IsDeleted => Deleted > 0;

    [SugarColumn(IsIgnore = true)]
    public List<OuInfo> Children { get; set; } = new List<OuInfo>();

    public OuInfo()
    {
        PID = -1;
        Deleted = 0;
        Enabled = 1;
        CreateTime = DateTime.Now;
        EditTime = DateTime.Now;
    }
}